<?php
namespace Admin\Controller;
use Think\Controller;
class UserController extends BaseController {
    public function index(){
    	$this->list = M("User")->Order('uid DESC')->Select();
		$this->display();
    }
    public function release(){
		if (!IS_POST) {
        	$this->display();
        }
        if (IS_POST) {
         	
        }
    }
    public function editor(){
		if (!IS_POST) {
        	$this->display();
        }
        if (IS_POST) {
         	
        }
    }
    public function delete(){
		
    }
    public function state(){
		
    }
    public function wechat(){
    	$this->list = M("Wxuser")->Order('uid DESC')->Select();
		$this->display();
    }
    public function wechatdelete($id){
     	if (!empty($id)) {
            $model = M("Wxuser");
            $result = $model->delete($id);
            if (false !== $result) {
                $this->success('删除成功！');
            } else {
                $this->error('删除出错！');
            }
        } else {
            $this->error('编号错误！');
        }
    }
    public function wechatlock($id){
     	$model = M("Wxuser");
        //查询该条信息的state字段值
        $result = $model->find($id);
        //更新字段
        $data['uid']=$id;
        if($result['lock'] == 1){
          $data['lock']=0;
        }
        if($result['lock'] == 0){
          $data['lock']=1;
        }
        if($model->save($data)){       	
            $this->success('状态更新成功!',U('user/wechat'),1);
        }else{
            $this->error('状态更新失败',U('news/index'),1);
        }
    }
    
}